<?php
header("Content-Type: text/html; charset=iso-8859-1");
require_once('include.php');
$_SESSION['navigation'] = 'documents';
$_SESSION['cat'] = 'documents';
$membre = check_cookie();
entete('VBCLL - Documents');
echo "<h1>Les documents</h1>";
$table = new table("documents");
$fields = array("nouv","type","nom","date");
foreach($fields as $field){
	$$field = new table_field($field,"documents");
	$$field->print = ($field == 'nouv') ? "&nbsp;" : $field;
	if($field != "nom") $$field->styleclass = 'center';
	$table->fields[$field] = $$field;
}
// $table->sort('date');
$q = "select id from documents where valide = 1";
if(!$membre) $q .= " and droits = '' or droits is null ";
elseif($membre && !check_admin()) $q .= " and droits = '' or droits is null or droits = 'm'";
$q .= " order by nom";
$r = ExecRequete($q);
while($s = LigneSuivante($r)){
	$row = new table_row();
	$file = new document($s->id);
	$row->onclick = "onclick = 'self.location.href=\"documents/$file->fichier\"'";
	$row->styleclass = 'pointer';
	$row->cols['nouv'] = ($file->date('Ymd') > date('Ymd',mktime(0, 0, 0, date("m")-1, date("d"),   date("Y")))) ? "<span class = 'bold non sup'>nouveau</span>" : "";
	$row->cols['type'] = $file->icon();
	$row->cols['nom'] = $file->nom;
	$row->cols['date modif'] = $file->date();
	$table->rows[] = $row;
}
echo $table->print_header();
echo $table->print_body();
echo $table->print_footer();

pied();
?>
